/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gcliff.rowMapper.glpks;

import com.gcliff.model.glpks.Sso;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.RowMapper;

/**
 *
 * @author krishna Code belongs to GCliff.
 */
public class SsoRM implements RowMapper<Object> {

    public Object mapRow(ResultSet resultSetOBJ, int line) throws SQLException {
        SsoRowMapper rowMapper = new SsoRowMapper();
        return rowMapper.extractData(resultSetOBJ);
    }
}

class SsoRowMapper implements ResultSetExtractor<Object> {

    BeanFactory factory = (BeanFactory) (new ClassPathXmlApplicationContext(new String[]{"classpath:appContextWeb.xml"}));

    public Object extractData(ResultSet resultSetOBJ) throws SQLException {
        Sso setterMapObject = (Sso) factory.getBean("sso");
        setterMapObject.setCrtbSsoId(resultSetOBJ.getString("CRTB_SSO_ID"));
        setterMapObject.setCode(resultSetOBJ.getString("CODE"));
        setterMapObject.setUserName(resultSetOBJ.getString("USER_NAME"));
        setterMapObject.setPassword(resultSetOBJ.getString("PASSWORD"));
        setterMapObject.setFirstName(resultSetOBJ.getString("FIRST_NAME"));
        setterMapObject.setMiddleName(resultSetOBJ.getString("MIDDLE_NAME"));
        setterMapObject.setLastName(resultSetOBJ.getString("LAST_NAME"));
        setterMapObject.setShortName(resultSetOBJ.getString("SHORT_NAME"));
        setterMapObject.setCrtbSsoActSts(resultSetOBJ.getString("CRTB_SSO_ACT_STS"));
        setterMapObject.setRecDelSts(resultSetOBJ.getString("REC_DEL_STS"));
        setterMapObject.setCrtbProjectId(resultSetOBJ.getString("CRTB_PROJECT_ID"));
        setterMapObject.setCrtbRoleId(resultSetOBJ.getString("CRTB_ROLE_ID"));
        setterMapObject.setCreatedDt(resultSetOBJ.getDate("CREATED_DT"));
        setterMapObject.setUpdatedDt(resultSetOBJ.getDate("UPDATED_DT"));
        setterMapObject.setCreatedBy(resultSetOBJ.getString("CREATED_BY"));
        setterMapObject.setUpdatedBy(resultSetOBJ.getString("UPDATED_BY"));
        setterMapObject.setRoleName(resultSetOBJ.getString("ROLE_NAME"));
        setterMapObject.setCrtbRoleActSts(resultSetOBJ.getString("CRTB_ROLE_ACT_STS"));
        return setterMapObject;
    }
}